Skip to content

Conversation

marenges
Copy link
Contributor

Added unit tests for subsys bm_nus

@marenges marenges requested review from a team as code owners August 29, 2025 13:27
Copy link

You can find the documentation preview for this PR here.

@marenges marenges force-pushed the ble_nus_unittests branch 2 times, most recently from 78523d0 to 643ac78 Compare August 29, 2025 13:31
Added unit tests for subsys bm_nus

Signed-off-by: Martin Engesvold <[email protected]>
TEST_ASSERT_EQUAL(BLE_GATTS_SRVC_TYPE_PRIMARY, type);
TEST_ASSERT_EQUAL(expected_uuid.type, p_uuid->type);
TEST_ASSERT_EQUAL(expected_uuid.uuid, p_uuid->uuid);
TEST_ASSERT_EQUAL(expected_conn_handle, *p_handle);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should set the conn_handle afterwards. Then we can check that this is propagated later.

struct ble_nus_client_context *last_link_ctx;

static uint32_t stub_sd_ble_gatts_service_add(uint8_t type, ble_uuid_t const *p_uuid,
uint16_t *p_handle, int calls)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Avoid hungarian notation (where we can, SoftDevice will still have it)

Suggested change
uint16_t *p_handle, int calls)
uint16_t *handle, int calls)

default:
return -1;
}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: extra newline

evt_handler_called = true;
}

static void init_nus(struct ble_nus_config *nus_cfg)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
static void init_nus(struct ble_nus_config *nus_cfg)
static void nus_init(struct ble_nus_config *nus_cfg)

TEST_ASSERT_EQUAL_PTR(nus_cfg->evt_handler, ble_nus.evt_handler);
}

static void setup_with_notif_enabled(uint16_t conn_handle)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the ble_nus_on_ble_evt here should be kept as a as a separate call after init in the test. It makes it a lot easier to follow each test and see the difference.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants